home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / gnu / djgpp / src / libgplus.5 / libgplus / etc / adt-exam / genpatke.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-17  |  634 b   |  32 lines

  1. // Generates random character strings
  2. #include <stream.h>
  3. #include <stdlib.h>
  4. #include <sys/types.h>
  5. #include <unistd.h>
  6.  
  7. main (int argc, char *argv[]) 
  8. {
  9.   if (argc != 3) 
  10.     {
  11.       cout << "usage: " << argv [0] << " number-of-keys length-of-keys\n";
  12.       return 1;
  13.     }
  14.   else
  15.     {
  16.       int Key_Number = atoi (argv [1]);     
  17.       int Key_Length = atoi (argv [2]);
  18.  
  19.       srand (getpid());
  20.  
  21.       for (int j = 0; j < Key_Number; j++)
  22.         {
  23.           for (int i = 0; i < Key_Length - (rand () % 20); i++) 
  24.             cout << char ('!' + rand () % (1+'~'-'!'));
  25.           cout << "\n";
  26.         }
  27.  
  28.       return 0;
  29.     }
  30.  
  31. }
  32.